package com.by.controller;


import com.by.common.AjaxResult.AjaxResult;
import com.by.entity.Supplier;
import com.by.service.SupplierService;
import com.by.utils.IfElse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/api")
@Api(tags = "供应商管理")
public class SupplierController {
    @Autowired
    private SupplierService supplierService;
    @ApiOperation("保存用户")
    @PostMapping("/supplier")
    public AjaxResult saveSupplier(@Valid @RequestBody Supplier supplier) {
        int num= supplierService.saveSupplier(supplier);
        if(num==0){
            return AjaxResult.error();
        }
        int num1= supplierService.saveSupplier(supplier);

        return IfElse.evaluate(num1);
    }
}
